<title>XSocial Test</title>
<script type="text/javascript" src="<?php echo $this->webRoot ?>js/xsocialRpc.js"></script>
<script>
//set correct value for xsocialApi.owner,xsocialApi.friends
//do authencation with sig = md5(sessionkey + uid + secretkey)
//put sessionkey,uid,sig in url GET parameters
//implement method like invite(),adjustHeight(),post(),payment()
//then call initRpc();
</script>
<?php
$userid = $_REQUEST["uid"];
if (empty($userid)) $userid = 1;
$sessionkey = time();
$sig = md5($sessionkey . $userid . $this->secretKey);
?>
this is xsocial layer,<br>
app url:<?php echo $this->appIframeUrl ?><br>
userid : <?php echo $userid ?><br><hr>
<div id="xsocial-container"></div>
<script type="text/javascript">
var xsocialTestApi = {
    init : function() {
        var viewer = {};
        viewer.uid = <?php echo $userid ?>;
        viewer.name = "Test User";
        viewer.thumbnail = "http://head.xiaonei.com/photos/0/0/men_tiny.gif";
        viewer.gender = 1;
        viewer.birthday = "2000-1-1";
        
        xsocialTestApi.viewer = viewer;
        xsocialTestApi.uid = viewer.uid;
        xsocialTestApi.sessionkey = <?php echo $sessionkey ?>;
        xsocialTestApi.sig = "<?php echo $sig ?>";
        initRpc();
    },
    
    getViewer : function(callback) {
        if (callback) callback(xsocialTestApi.viewer);
    },
    
    getFriends : function(callback,opt) {
        var friends = [];
        friends.push(
        {"uid":<?php echo $userid + 1 ?>,"name":"Test Friends No.1","thumbnail":"http://head.xiaonei.com/photos/0/0/men_tiny.gif"},
        {"uid":<?php echo $userid + 2 ?>,"name":"Test Friends No.2","thumbnail":"http://head.xiaonei.com/photos/0/0/men_tiny.gif"},
        {"uid":<?php echo $userid + 3 ?>,"name":"Test Friends No.3","thumbnail":"http://head.xiaonei.com/photos/0/0/men_tiny.gif"}
        );
        
        if (callback) callback(friends);
    },
    invite : function(bundleData,callback) {
        alert("invite not implemented.");
    },
    payment : function() {
        alert("payment not implemented.");
    },
    adjustHeight : function() {
    },
    post : function(bundleData, callback) {
        //TODO: test bundleData fields  
        alert('post is not implemented');
    }
};

var xsocialApi = xsocialTestApi;
</script>
<script>
var ifrSrc = "<?php echo $this->appIframeUrl ?>";
xsocialApi.init();
</script>